﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace ciiattack
{
    public class EnemyManager
    {
        private Texture2D enemyTexture;
        private Vector2 enemyOrigin;
        private SpriteBatch spriteBatch;
        private List<Enemy> enemies;

        public List<Enemy> Enemies
        {
            get { return enemies; }
        }

        public EnemyManager(Texture2D enemyTexture, Vector2 enemyOrigin, SpriteBatch spriteBatch)
        {
            this.enemyTexture = enemyTexture;
            this.enemyOrigin = enemyOrigin;
            this.spriteBatch = spriteBatch;

            enemies = new List<Enemy>();
        }

        public void Update(GameTime gameTime)
        {
            foreach (Enemy e in enemies)
            {
                e.Update(gameTime);
            }
        }

        public void Draw(GameTime gameTime)
        {
            foreach (Enemy e in enemies)
            {
                e.Draw(gameTime);
            }
        }

        public void StartTheGame(Int32 enemyCount)
        {
            Random random = new Random();
            enemyCount = random.Next(6) + 3;

            for (Int32 i = 0; i < enemyCount; i++)
            {
                enemies.Add(new Enemy(this.enemyTexture, this.enemyOrigin, this.spriteBatch, new Vector2(32.0f + random.Next(176), -32.0f - random.Next(256))));
            }
        }
    }
}